package com.iap.admin.mediator
{
	import com.iap.admin.event.AdminHomeEvent;
	import com.iap.admin.event.AdminMenuEvent;
	import com.iap.admin.view.AdminMenuView;
	import com.iap.admin.view.AdminView;
	import com.iap.admin.view.FavoriteView;
	import com.iap.admin.view.FillerView;
	import com.iap.admin.view.ImageView;
	import com.iap.admin.view.SampleView;
	import com.iap.admin.view.TagView;
	import com.iap.admin.view.VectorView;
	import com.iap.admin.view.control.FavoriteButton;
	import com.iap.admin.view.control.FillerButton;
	import com.iap.admin.view.control.HomeButton;
	import com.iap.admin.view.control.ImageButton;
	import com.iap.admin.view.control.SampleButton;
	import com.iap.admin.view.control.TagButton;
	import com.iap.admin.view.control.VectorButton;
	import com.iap.app.util.GlideTransitionEffect;
	
	import flash.events.Event;
	
	import mx.controls.Alert;
	import mx.core.UIComponent;
	
	import org.robotlegs.mvcs.Mediator;
	
	import spark.components.Group;
	import com.iap.common.mediator.BaseMediator;
	
	public class AdminMediator extends BaseMediator
	{
		[Inject]
		public var view:AdminView;

		override public function onRegister():void
		{
			addContextListener(AdminMenuEvent.SELECTED, menuHandler);
			addContextListener(AdminHomeEvent.CLICK, optionHome);
		}
		
		private function menuHandler(evt:AdminMenuEvent):void
		{
			switch(evt.menuName)
			{
				case HomeButton.NAME:
				{
					optionHome();
					break;
				}
				case SampleButton.NAME:
				{
					optionSample();
					break;
				}
				case ImageButton.NAME:
				{
					optionImage();
					break;
				}
				case VectorButton.NAME:
				{
					optionVector();
					break;
				}
				case TagButton.NAME:
				{
					optionTag();
					break;
				}
				case FillerButton.NAME:
				{
					optionFiller();
					break;
				}
				case FavoriteButton.NAME:
				{
					optionFavorite();
					break;
				}
				default:
				{
					//Alert.show(""+ evt.menuName);
					break;
				}
			}
		}
		
		private function optionHome(evt:Event = null):void
		{
			setView(view.adminGroup, new AdminMenuView());
		}

		private function optionSample():void
		{
			setView(view.adminGroup, new SampleView());
		}

		private function optionImage():void
		{
			setView(view.adminGroup, new ImageView());
		}

		private function optionVector():void
		{
			setView(view.adminGroup, new VectorView());
		}

		private function optionTag():void
		{
			setView(view.adminGroup, new TagView());
		}

		private function optionFiller():void
		{
			setView(view.adminGroup, new FillerView());
		}

		private function optionFavorite():void
		{
			setView(view.adminGroup, new FavoriteView());
		}
	}
}